package com.design.tempelate;

import java.text.SimpleDateFormat;
import java.util.Date;

public abstract class Worker extends CommonWorker{

    protected String name;
     SimpleDateFormat simpleDateFormat;
    String sdfStr="yyyy-MM-dd HH:mm:ss";
    public Worker(String name){
        simpleDateFormat=new SimpleDateFormat(sdfStr);
        this.name=name;
    }

    public final void workOneDay(){
        enterCompany();
        computerOn();
        work();
        computerOff();
        leaveCompany();
    }

    public abstract void work();

    public void computerOn(){
        loginfo(name+" 打开电脑");
    }
    public void computerOff(){
        loginfo(name+" 关闭电脑");
    }

    public void enterCompany(){
        loginfo(name+" 进入公司");
    }
    public void leaveCompany(){
        if(isNeedPringDate()){
            loginfo(name+ simpleDateFormat.format(new Date())+" 离开公司");
        }else{
            loginfo(name+" 离开公司");
        }

    }

    public boolean isNeedPringDate(){
        return false;
    }



}
